package com.redhipps.hips.client.widget;

import java.util.List;

import com.google.gwt.user.client.ui.Hyperlink;
import com.redhipps.hips.client.model.Context;
import com.redhipps.hips.client.model.ScheduleSolution;

public class ScheduleSolutionList extends ModelList<ScheduleSolution> {

  private static String[] HEADERS = {"Solution"};

  public ScheduleSolutionList(Context ctx, List<ScheduleSolution> values) {
    super(ctx, values);
    refresh();
  }

  @Override
  protected Object[] headers() {
    return HEADERS;
  }

  @Override
  protected Object[] writeModel(ScheduleSolution model, int row) {
    String message = model.getMessage();
    if (message.length() > 50) {
      message = message.substring(0, 47) + "...";
    }
    Hyperlink hyperlink = new Hyperlink(message, "");
    hyperlink.addClickListener(createModelSelectionClickListener(model));
    return new Object[] { hyperlink };
  }

}
